<template>
	<view class="personal" :style="{direction:i18nLocale=='ug'?'rtl':''}">
		<TopBar :indexflag="true" :combakflag="true" :lang="false" :bottom="true" title="个人中心"
			barstyle="background-color:rgba(0,0,0,0)"></TopBar>
		<view :class="i18nLocale=='ug'?'input-from ug-from':'input-from'">
			<view class="input-item">
				<view class="title">
					{{$t('UserName')}}
				</view>
				<u--input :placeholder="$t('NamePlaceholder')" fontSize="28rpx" autoBlur border="bottom"
					:adjustPosition='false'></u--input>
			</view>
			<view class="input-item">
				<view class="title">
					{{$t('UserNumber')}}
				</view>
				<u--input :placeholder="$t('NamePlaceholder')" border="bottom" fontSize="28rpx"
					:adjustPosition='false'></u--input>
			</view>
		</view>
		<view class="selecet-addres">
			<view class="title">
				{{$t('DefaultAddress')}}
			</view>
		</view>
		<view class="address" v-if="addressList.length!=0" v-for="(item,index) in addressList">
			<view class="left">
				<view class="user">
					<view class="name">{{item.name}}</view>
					<view class="pone">{{item.pone}}</view>
				</view>
				<view class="address-title">{{item.address}}</view>
				<view class="address-title">{{item.title}}</view>
			</view>
			<view class="right">
				<u-icon name="edit-pen" color="#15c45b" size="25"></u-icon>
				<view :class="ac_radio==index?'raio acradio':'raio'" @click="selecetAddress(index)">
					<u-icon v-if="ac_radio==index" name="checkbox-mark" color="#fff" size="20"></u-icon>
				</view>
			</view>
		</view>

		<view class="no-address" v-if="addressList.length==0" @click="addAddress">
			<u-empty mode="address" text="地址列表为空">
			</u-empty>
		</view>
		<view class="save-button" @click="changesave">{{$t('Save')}}</view>
	</view>
</template>

<script>
	import TopBar from "@/components/TopBar.vue"
	export default {
		components: {
			TopBar
		},
		data() {
			return {
				ac_radio: 0,
				addressList: [{
						name: 'aili',
						pone: '17690927591',
						address: '新疆喀什市深圳城3号楼',
						title: '喀什市政府'
					},
					{
						name: 'aili',
						pone: '17690927591',
						address: '新疆喀什市深圳城3号楼',
						title: '喀什市政府'
					},
				]
			};
		},
		computed: {
			i18nLocale() {
				return this.$i18n.locale;
			},
		},
		methods: {
			addAddress() {
				uni.navigateTo({
					url: '/pages/me/address/add_address'
				})
			},
			selecetAddress(index) {
				this.ac_radio = index;
			}
		}
	}
</script>

<style lang="scss">
	.personal {
		padding: $uni-spacing-padding-sm;
		box-sizing: border-box;

		.input-from {
			background-color: #fff;
			width: 100%;
			padding: 10rpx 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;

			.input-item {
				width: 100%;
				// display: flex;
				padding: $uni-spacing-padding-sm;
				box-sizing: border-box;

				input {
					font-size: $uni-font-size-base;

				}

				.title {
					color: $uni-color-title;
					font-size: $uni-font-size-base;
				}
			}
		}

		.selecet-addres {
			background-color: #fff;
			width: 100%;
			padding: 20rpx 40rpx;
			box-sizing: border-box;
			margin-top: $uni-spacing-margin-sm;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;
			color: $uni-color-title;
			font-size: $uni-font-size-base;



		}

		.no-address {
			margin-top: 100rpx;

			text {
				padding: 0rpx 20rpx;
			}
		}

		.address {
			// border-bottom: 2rpx solid;
			display: flex;
			margin-bottom: 20rpx;
			background-color: $uni-bg-color-box;
			width: 100%;
			padding: 30rpx 40rpx;
			box-sizing: border-box;
			margin-top: $uni-spacing-margin-sm;
			border-radius: $uni-border-radius-lg;
			box-shadow: $uni-bg-shadow;

			.left {
				width: 70%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: $uni-font-size-sm1;

				.user {
					display: flex;

					.name {
						color: #15c45b;
						font-weight: bold;
					}

					.pone {
						padding: 0rpx 40rpx;
						box-sizing: border-box;
					}

				}

				.address-title {
					margin-top: 10rpx
				}
			}

			.right {
				width: 30%;
				display: flex;
				align-items: center;
				justify-content: space-around;

				.raio {
					width: 50rpx;
					height: 50rpx;
					border-radius: 100%;
					border: 4rpx solid $uni-border-color;
					display: flex;
					justify-content: center;
					align-items: center;

				}

				.acradio {
					border: 4rpx solid $uni-color-topic;
					background-color: $uni-color-topic;
				}
			}

		}

		.save-button {
			width: 90%;
			margin: 20rpx auto;
			background-color: $uni-color-topic;
			color: #fff;
			font-size: $uni-font-size-lg;
			padding: $uni-spacing-padding-sm 0rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: $uni-border-radius-lg;
			position: fixed;
			bottom: 5%;
			left: 5%;
		}
	}
	.ug-from{
		/deep/ .uni-input-input {
			direction: rtl !important;
			text-align: right;
		}
		/deep/ .uni-input-placeholder {
			text-align: right;
		}
	}
</style>